package com.heo.pojo;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.annotation.JSONField;


/**
 * 基础实体对象
 * 
 * @author penggl
 * @version 1.0
 * @date 2017-5-29
 */
public class BaseEntity implements Serializable
{
  private static Logger log = LoggerFactory.getLogger(BaseEntity.class);
  /**
   * 
   */
  private static final long serialVersionUID = 1L;

  /**
   * 用于排序
   */
  @JSONField(serialize=false)
  private String sortName;
  @JSONField(serialize=false)
  private String sortOrder;

  public String getSortName()
  {
    this.sortName = this.sortName == null ? "1" : this.sortName;
    if (sortName.length() > 20)
    {
      log.error("[SQL防注入]sortName参数长度超过制定的长度，sortName:" + sortName);
      return "1";
    }
    else
    {
      return sortName;
    }
  }

  public void setSortName(String sortName)
  {
    this.sortName = sortName;
  }

  public String getSortOrder()
  {
    this.sortOrder = this.sortOrder == null ? "desc" : this.sortOrder;
    if ("asc".equalsIgnoreCase(sortOrder) || "desc".equalsIgnoreCase(sortOrder))
    {
      return this.sortOrder;
    }
    else
    {
      return "desc";
    }
  }

  public void setSortOrder(String sortOrder)
  {
    this.sortOrder = sortOrder;
  }

}
